import os

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
url = "file:///" + os.path.abspath("html") + "/frame.html"
driver.get(url)
driver.switch_to.frame("f1")
inner_h3 = driver.find_element(By.ID, 'inner_h3')
print(inner_h3.get_attribute("outerHTML"))
#切换FRame f2
f2 = driver.find_element(By.ID, 'f2')
driver.switch_to.frame(f2)
print(driver.find_element(By.ID, 'p1').get_attribute('outerHTML'))
# @切换到父级
driver.switch_to.parent_frame()
#切换到主页面
driver.switch_to.default_content()
print(driver.find_element(By.TAG_NAME, 'h3').get_attribute("otterHTML"))
# driver.quit()